﻿using System;
using Business;

namespace UI_Main
{
    public partial class Resolve : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.RequestType == "POST")
            {
                try
                {
                    string action = Request.QueryString["action"].ToLower();
                    string id = Request.QueryString["id"];
                    if(action.Equals("deletearticle")){
                        var articleBusiness = new ArticleBusiness();
                        if (articleBusiness.Block(Guid.Parse(id)))
                        {
                            Response.Write("True:Đã chuyển vào thùng rác");
                        }
                        else
                        {
                            Response.Write("False:Không xóa được");
                        }
                    }
                    if (action.Equals("deletecomment"))
                    {
                        var commentBusiness = new CommentBusiness();
                        if (commentBusiness.Delete(Guid.Parse(id)))
                        {
                            Response.Write("True:Đã xoá");
                        }
                        else
                        {
                            Response.Write("False:Không xóa được");
                        }
                    } 
                }
                catch (Exception ex)
                {
                    Response.Write(String.Format("False:{0}", ex.Message));
                }
            }
            else
            {
                Response.Redirect("Default.aspx");
            }
            Response.End();
        }
    }
}